<!--
  ~ Copyright [2021-2021] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<nz-table #innerTable [nzData]="instances" nzSize="middle" [nzShowPagination]="false">
  <thead>
  <tr>
    <th>Schema</th>
    <th>Host</th>
    <th>Port</th>
    <th>Weight</th>
    <th>Ephemeral</th>
    <th>TtlAt</th>
    <th>Metadata</th>
    <th>Action</th>
  </tr>
  </thead>
  <tbody>
  <tr *ngFor="let instance of innerTable.data">
    <td>{{ instance.schema }}</td>
    <td>{{ instance.host }}</td>
    <td>{{ instance.port }}</td>
    <td>{{ instance.weight }}</td>
    <td>{{ instance.ephemeral }}</td>
    <td>{{ (instance.ttlAt ? instance.ttlAt : 0) * 1000  | date:'yyyy-MM-dd HH:mm:ss'}}</td>
    <td>{{ instance.metadata|json }}</td>
    <td>
      <nz-button-group>
        <button
          nz-popconfirm
          [nzPopconfirmTitle]="'Are you sure delete this instance?'"
          nzPopconfirmPlacement="top"
          nz-button
          (nzOnConfirm)="deregister(instance)"
        >
          <i nz-icon nzType="delete" nzTheme="outline"></i>
        </button>

        <button
          nz-button
          (click)="openEditInstance(instance.serviceId,instance)"
        >
          <i nz-icon nzType="edit" nzTheme="outline"></i>
        </button>
      </nz-button-group>
    </td>
  </tr>
  </tbody>
</nz-table>
